
<?php	
	
	class department extends database
	{
		var $connection = '';	

		function department()
		{
			parent::database();
		}
	
		function GetListPaging()
		{						
			$this->setQuery("set names utf8");
			$this->query();
			return $sql = "Select * from tbldepartment";			
			//return $pager;
			//$rs = $pager->paginate();
	//Loop through the result set
				
			/*$this->setQuery($sql);
			$value = $this->loadAllRow();
			return $value;*/
		}
		
		function GetList()
		{						
			$this->setQuery("set names utf8");
			$this->query();			
			$sql = "SELECT * from tbldepartment ";			
			$this->setQuery($sql);
			$value = $this->loadAllRow();
			return $value;
		}
        
        function AddDepartment($DepartmentName, $SourceCode, $ActiveYN)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "Insert into tbldepartment(`DepartmentName`, `SourceCode`, `ActiveYN`) 
            values('".$DepartmentName."', '".$SourceCode."', '".$ActiveYN."')";
            //echo $sql;
			$this->setQuery($sql);
			$this->query();
		}
		
		function UpdateDepartment($DepartmentName, $SourceCode, $ActiveYN, $id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "";
			$sql = "Update tbldepartment set `DepartmentName` =  '".$DepartmentName."', 
            `SourceCode` = '".$SourceCode."', 
            `ActiveYN` = '".$ActiveYN."'";
			$sql .= " where DepartmentID=".$id;	
            //echo $sql;		
			$this->setQuery($sql);
			$this->query();
		}
		
		function GetOneDepartment($id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "Select * from tbldepartment where DepartmentID=".$id."";
			$this->setQuery($sql);
			$row = $this->loadOneRow();
			return $row;
		}
		
		function DeleteDepartment($id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "";
			$sql = "Delete from tbldepartment ";
			$sql .= " where DepartmentID=".$id;			
			
			$this->setQuery($sql);
			$this->query();
		}
	
		
	}
?>